{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8917bc55",
   "metadata": {},
   "source": [
    "## gensim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "866e5b3e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T15:01:33.645721Z",
     "start_time": "2023-06-29T15:01:33.638003Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import gensim\n",
    "import gensim.downloader as api\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "72758b55",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T15:01:35.658453Z",
     "start_time": "2023-06-29T15:01:35.648458Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'4.3.1'"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gensim.__version__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "d3dbe1f0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:38:58.205029Z",
     "start_time": "2023-06-29T14:38:58.199386Z"
    }
   },
   "outputs": [],
   "source": [
    "# import os\n",
    "# os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'\n",
    "# os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f70877b",
   "metadata": {},
   "source": [
    "## embedding matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1be9f18b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:24:54.163375Z",
     "start_time": "2023-06-29T14:23:53.054973Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[==================================================] 100.0% 66.0/66.0MB downloaded\n"
     ]
    }
   ],
   "source": [
    "# glove-wiki-gigaword-100\n",
    "# glove-wiki-gigaword-300\n",
    "model = api.load('glove-wiki-gigaword-50')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "654e9a5e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:54:34.052892Z",
     "start_time": "2023-06-29T14:54:34.041519Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['fasttext-wiki-news-subwords-300', 'conceptnet-numberbatch-17-06-300', 'word2vec-ruscorpora-300', 'word2vec-google-news-300', 'glove-wiki-gigaword-50', 'glove-wiki-gigaword-100', 'glove-wiki-gigaword-200', 'glove-wiki-gigaword-300', 'glove-twitter-25', 'glove-twitter-50', 'glove-twitter-100', 'glove-twitter-200', '__testing_word2vec-matrix-synopsis'])"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import json\n",
    "json.load(open(os.path.expanduser('~') + '/gensim-data/information.json'))['models'].keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "0d95c4e7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T15:02:42.015017Z",
     "start_time": "2023-06-29T15:02:41.983735Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(400000, 50)\n",
      "-5.4593\n",
      "5.3101\n"
     ]
    }
   ],
   "source": [
    "print(model.vectors.shape)\n",
    "print(model.vectors.min())\n",
    "print(model.vectors.max())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "21c2668f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:49:17.366411Z",
     "start_time": "2023-06-29T14:49:16.082152Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAGdCAYAAAD+JxxnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy88F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1c6dO0d71HFjqPv0wn8QT548qQceeEDp6enasWOHbrqJ/8cZqr6+Pt188836zW9+o4cffthe/9Of/lRNTU06ePBgEKcb39asWaPXX39dNTU1SkpKCvY449rrr7+uhx9+WGFhYfa6gYEBORwO3XTTTfL7/QHbMHQUIdwwLS0t6urqsh+fPHlS8+fP17/9278pPT1dt912WxCnG78+//xzPfDAA0pLS1NpaSn/MbwG6enpSktL0/PPP2+vmzFjhn7wgx9wsfQ1sCxLa9asUXl5uQ4cOKA77rgj2CONe+fOndOf//zngHX//M//rLvuuks/+9nPOO14HbhGCDfMlClTAh7/wz/8gyTp9ttvpwRdo5MnT2rOnDmaMmWKtmzZotOnT9vb3G53ECcbXwoKCuT1ejVz5kxlZGToxRdfVEtLi1asWBHs0calVatWac+ePfr3f/93RUVF2ddauVwuRUREBHm68SkqKuqSshMZGalbbrmFEnSdKELAOFZZWak//vGP+uMf/3hJmeRg79AtW7ZMZ86c0aZNm9TW1qaUlBS9+eabmjp1arBHG5cufA3BnDlzAta/8sorys3NvfEDAYPg1BgAADAWV1QCAABjUYQAAICxKEIAAMBYFCEAAGAsihAAADAWRQgAABiLIgQAAIxFEQIAAMaiCAEAAGNRhAAAgLEoQgAAwFgUIQAAYKz/B5EzutDq8BGLAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "_ = plt.hist(model.vectors)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5e2c6b8c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:25:04.402207Z",
     "start_time": "2023-06-29T14:25:04.395547Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.50451 ,  0.68607 , -0.59517 , -0.022801,  0.60046 , -0.13498 ,\n",
       "       -0.08813 ,  0.47377 , -0.61798 , -0.31012 , -0.076666,  1.493   ,\n",
       "       -0.034189, -0.98173 ,  0.68229 ,  0.81722 , -0.51874 , -0.31503 ,\n",
       "       -0.55809 ,  0.66421 ,  0.1961  , -0.13495 , -0.11476 , -0.30344 ,\n",
       "        0.41177 , -2.223   , -1.0756  , -1.0783  , -0.34354 ,  0.33505 ,\n",
       "        1.9927  , -0.04234 , -0.64319 ,  0.71125 ,  0.49159 ,  0.16754 ,\n",
       "        0.34344 , -0.25663 , -0.8523  ,  0.1661  ,  0.40102 ,  1.1685  ,\n",
       "       -1.0137  , -0.21585 , -0.15155 ,  0.78321 , -0.91241 , -1.6106  ,\n",
       "       -0.64426 , -0.51042 ], dtype=float32)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model[\"king\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "8e101474",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:32:35.358949Z",
     "start_time": "2023-06-29T14:32:35.348953Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.3744817"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linalg.norm(model['king'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "11805902",
   "metadata": {},
   "source": [
    "## similar/distance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f5d80616",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:25:40.126308Z",
     "start_time": "2023-06-29T14:25:39.993678Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('prince', 0.8236179351806641),\n",
       " ('queen', 0.7839043140411377),\n",
       " ('ii', 0.7746230363845825),\n",
       " ('emperor', 0.7736247777938843),\n",
       " ('son', 0.766719400882721),\n",
       " ('uncle', 0.7627150416374207),\n",
       " ('kingdom', 0.7542160749435425),\n",
       " ('throne', 0.7539914846420288),\n",
       " ('brother', 0.7492412328720093),\n",
       " ('ruler', 0.7434253096580505)]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.most_similar(\"king\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "e0fc21de",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:29:42.259328Z",
     "start_time": "2023-06-29T14:29:42.247188Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.82361794"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "king = model[\"king\"]\n",
    "prince = model['prince']\n",
    "\n",
    "king_norm = np.linalg.norm(king)\n",
    "prince_norm = np.linalg.norm(prince)\n",
    "np.dot(king, prince) / (king_norm * prince_norm)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4602286b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:27:50.254574Z",
     "start_time": "2023-06-29T14:27:50.246027Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.82361794], dtype=float32)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.cosine_similarities(king, [prince])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "2b81ac5a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:37:22.442093Z",
     "start_time": "2023-06-29T14:37:22.434215Z"
    }
   },
   "outputs": [],
   "source": [
    "def cos_sim(v1, v2):\n",
    "    v1_norm = np.linalg.norm(v1)\n",
    "    v2_norm = np.linalg.norm(v2)\n",
    "    return np.dot(v1, v2) / (v1_norm * v2_norm)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a845d9d",
   "metadata": {},
   "source": [
    "## 可视化分析"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "79d2ab45",
   "metadata": {},
   "source": [
    "- heatmap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "19766ba0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T15:05:46.202928Z",
     "start_time": "2023-06-29T15:05:46.026036Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABBIAAABvCAYAAABRq+PKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy88F64QAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAJ8UlEQVR4nO3dfWxV5R0H8F9b6G3RphsyXjJEC5gNZ5bFggQyedkyUqKJLnPDLTFZAiwOZGEsJjiWFchclyiMzIxGxhJjDMpegibqDM02XhbmhuhC3AYZbIaIoJSxRoHeW8rdH0bmBabnck893Pr5JOePc+j5nV8KveX55nmeU1MsFosBAAAAkEBt1g0AAAAA1UOQAAAAACQmSAAAAAASEyQAAAAAiQkSAAAAgMQECQAAAEBiggQAAAAgMUECAAAAkJggAQAAAEhMkAAAAAAkJkgAAACAKtXR0RFTpkyJpqamGDlyZNx+++2xf//+AX2mIAEAAACq1Pbt22Px4sXx/PPPR1dXV5w5cybmzJkTJ0+eHLBn1hSLxeKAVQcAAAA+MMeOHYuRI0fG9u3bY8aMGQPyDDMSAAAAYJDo6emJiIjhw4cP2DPMSAAAAIDLSD6fj3w+X3Itl8tFLpd7z/uKxWLcdtttceLEidi5c+eA9WdGAgAAAGRpWH3J0dHREc3NzSVHR0fH+5a55557Yu/evfH4448PaLtlzUjY0b02lYfOGLEs/n6gveI6kyauitZX/5FCRxF7xl4X34/fVFxndcyNF1/9YQodRdw49ruxtPj7VGqtq5kd9xa7Kq7zQM0X4nf/Xld5QxHxueFL48ZDlf/9vTjuuvha/s8pdBSxKXdTLI+tqdT6UcyJmN9aeaGf74kV8VzldSLi/miLuue6K67T3zYilZ/hiLd/jl9/4Tup1Bo1eU3MOPa3iuvs+Nj1cWf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su8TJAAAAECGzp+RkM/nI5/Pl1zL5XKRy+VSe+bBgwfjoYceijVr1pR9b02xWCym1gkAAABQkZUrV8aqVatKrrW3t8fKlSsTfe35du/eHZMnTz53/tprr8XMmTNj5syZsXHjxrL7EyQAAADAZaScGQnd3d3R3d39nvWuvfbaaGhoiIi3Q4TZs2fH1KlT45FHHona2vJf5ihIAAAAgA+Bw4cPx+zZs6O1tTUee+yxqKuru6Q6ggQAAAAY5N5ZzjBu3Lh49NFHS0KE0aNHl1XLZosAAAAwyG3dujUOHDgQBw4ciLFjx5b8WbnzC8xIAAAAABIrf1cFAAAA4ENLkAAAAAAkJkgAAAAAEhMkAAAAAIkJEgAAAIDEBAkAAABAYoIEAAAAIDFBAgAAAJCYIAEAAABITJAAAAAAJCZIAAAAABITJAAAAACJ/RcqRj0Jr3aHFwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1500x100 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(15,1))\n",
    "sns.heatmap([model[\"king\"]], xticklabels=False, yticklabels=False, cbar=True,\n",
    "            vmin=-2, vmax=2, linewidths=0.7, cmap='rainbow')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "7be8c02e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T15:06:08.894875Z",
     "start_time": "2023-06-29T15:06:08.884243Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.50451 ,  0.68607 , -0.59517 , -0.022801,  0.60046 , -0.13498 ,\n",
       "       -0.08813 ,  0.47377 , -0.61798 , -0.31012 , -0.076666,  1.493   ,\n",
       "       -0.034189, -0.98173 ,  0.68229 ,  0.81722 , -0.51874 , -0.31503 ,\n",
       "       -0.55809 ,  0.66421 ,  0.1961  , -0.13495 , -0.11476 , -0.30344 ,\n",
       "        0.41177 , -2.223   , -1.0756  , -1.0783  , -0.34354 ,  0.33505 ,\n",
       "        1.9927  , -0.04234 , -0.64319 ,  0.71125 ,  0.49159 ,  0.16754 ,\n",
       "        0.34344 , -0.25663 , -0.8523  ,  0.1661  ,  0.40102 ,  1.1685  ,\n",
       "       -1.0137  , -0.21585 , -0.15155 ,  0.78321 , -0.91241 , -1.6106  ,\n",
       "       -0.64426 , -0.51042 ], dtype=float32)"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model[\"king\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "af4b9182",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:36:15.873519Z",
     "start_time": "2023-06-29T14:36:15.647520Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABB0AAAFICAYAAAAcfoZ9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy88F64QAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAbUUlEQVR4nO3de5BdVZko8HW6gSaQGIgZgopIAKdEGRQD1wmvSXxgwmsQQaII5krQEAKFragNFgRK6FExUohEECWigDgIyAAi8YFBUK9BuAwqjEGcjEBQHkYToEP67PvH3FndDRiTvXr1Cju/X9Wu+s6hz7e/3ek+ffjqW2u3qqqqAgAAAMAw6yhdAAAAANBMmg4AAABAFpoOAAAAQBaaDgAAAEAWmg4AAABAFpoOAAAAQBaaDgAAAEAWmg4AAABAFpoOAAAAQBablC4AAAAANmqtVtrrq2p46shA0wEAAABK6mzuIoT1bjrc8qfPJ51w/61OjPGSh3pr59njFT0xPmzVnUk1XbPlpBj3hm/XztMT/jnGP/7jZ5Nq2ufvPhzj08N3knKdFaYPim+snef0cGCMv/PnC5Jqmv6SuTE+dOUvaue5bvQbY3xS+9aUksL5HVNi/MlwQ1KuT4SDBh5c9I76iT54bQxTfjZDGPrzuduDD9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0HQAAAIAsNB0AAACALDQdAAAAgCw0HQAAAIAsNB0AAACALDQdAAAAgCz+H7tJm5lDDPLqAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 1500x400 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# king - man = queen - woman\n",
    "# king - man + woman = queen\n",
    "# king + woman - man = queen\n",
    "plt.figure(figsize=(15,4))\n",
    "sns.heatmap([model[\"king\"], \n",
    "             model[\"man\"], \n",
    "             model[\"woman\"], \n",
    "             model[\"king\"] - model[\"man\"] + model[\"woman\"],\n",
    "             model[\"queen\"],\n",
    "            ], cbar=True, xticklabels=False, yticklabels=False,linewidths=1, cmap='rainbow') \n",
    "plt.show()\n",
    "     "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "3dcdf185",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T14:38:34.251417Z",
     "start_time": "2023-06-29T14:38:34.239654Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.7839043, 0.5366701, 0.6003106, 0.86095804]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[cos_sim(model[\"queen\"], v) for v in \n",
    "    [model['king'], model['man'], model['woman'], model[\"king\"] - model[\"man\"] + model[\"woman\"]]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "f701919b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-06-29T15:08:01.485915Z",
     "start_time": "2023-06-29T15:08:01.472611Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.7839044 , 0.53666997, 0.60031056, 0.86095816], dtype=float32)"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.cosine_similarities(model[\"queen\"], \n",
    "                          [model['king'], \n",
    "                           model['man'], \n",
    "                           model['woman'],\n",
    "                           model[\"king\"] - model[\"man\"] + model[\"woman\"]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2d7b965e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
